import vue from '@vitejs/plugin-vue'
import { PluginOption } from 'vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
import eslintPlugin from 'vite-plugin-eslint'

/**
 * ts vue3 项目开发通用插件
 * @param command
 * @param mode
 * @param pluginArr
 * @param env
 */
export function setupCommPlugins(
  command: string,
  mode: string,
  pluginArr: (PluginOption | PluginOption[])[],
  env: Record<string, string>
) {
  console.log('process.cwd()', process.cwd())
  pluginArr.push(
    ...[
      vue(),
      vueJsx(),
      eslintPlugin({
        include: [
          'src/**/*.ts',
          'src/**/*.vue',
          'src/*.ts',
          'src/*.vue',
          'src/*.js',
          'src/**/*.jsx',
          'src/**/*.txs',
          'src/*.jsx',
          'src/*.tsx'
        ],
        cache: false
      })
    ]
  )
}
